First public contribution.
2 * Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
4 * This component and the accompanying materials are made available
5 * under the terms of "Eclipse Public License v1.0"
6 * which accompanies this distribution, and is available
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
9 * Initial Contributors:
10 * Nokia Corporation - initial contribution.
28 #include <techview/eikchlst.h>
32 #include <techview/eiktbar.h>
33 #include <techview/eikprtpv.h>
34 #include <techview/eikprtdg.h>
35 #include <techview/eikpword.h>
36 #include <techview/eikbtgpc.h>
37 #include <techview/eikon.rsg>
47 const TInt KZoomStateOne=660;
48 const TInt KZoomStateTwo=800;
49 const TInt KZoomStateThree=TZoomFactor::EZoomOneToOne;
50 const TInt KZoomStateFour=1500;
51 const TInt KDefaultZoomState=KZoomStateTwo;
53 const TInt KFirstPageNum=0;
55 const TInt KPrintPreviewBandsPerPage=6;
57 TBool CWordAppUi::ProcessCommandParametersL(TApaCommand aCommand ,TFileName& aDocumentName, const TDesC8& /*aTail*/)
59 {return CEikAppUi::ProcessCommandParametersL(aCommand,aDocumentName);}
62 void CWordAppUi::CreateEdwinL()
64 CGraphicsDevice* device=iCoeEnv->ScreenDevice();
65 iAppZoom.SetGraphicsDeviceMap(device);
66 iAppZoom.SetZoomFactor(KDefaultZoomState);
67 iRichEd=new(ELeave) CWordTextEditor(TGulBorder::ESingleBlack);
68 const TInt flags=EEikEdwinOwnsWindow|EEikEdwinKeepDocument|EEikEdwinInclusiveSizeFixed|EEikEdwinUserSuppliedText|
69 EEikEdwinNoAutoSelection|EEikEdwinAlwaysShowSelection;
70 iRichEd->ConstructL(NULL,0,0,flags);
71 iRichEd->SetObserver(this);
72 iRichEd->SetEdwinObserver(this);
73 iRichEd->CreateScrollBarFrameL();
74 iRichEd->ScrollBarFrame()->SetScrollBarVisibilityL(CEikScrollBarFrame::EOff, CEikScrollBarFrame::EAuto);
75 iRichEd->SetAdjacent(EGulAdjTop|EGulAdjRight);
76 iRichEd->SetZoomFactorL(&iAppZoom);
80 iTest = CWordTest::NewL(iRichEd->TextView());
81 iTest->TurnOnCustomDrawing(iRichEd->TextLayout());
83 // iRichEd->SetFocus(ETrue);
85 iRichEd->TextView()->SetParagraphFillTextOnly(ETrue); // call when text view has been initalised
86 SetReadOnly(iEmbeddedAndReadOnly);
90 void CWordAppUi::HandleModelChangeL()
92 iModel=Document()->Model();
95 ResetEdwinL(); // may use print data if in wysiwyg mode.
97 SetPaginationOutOfDate(ETrue);
98 iEikonEnv->BusyMsgCancel();
99 if (iRichEd->IsReadOnly())
100 iEikonEnv->InfoMsg(R_WORD_FILE_READ_ONLY);
101 iRichEd->TextView()->SetCursorPlacement(ECursorVertical);
105 void CWordAppUi::ReformatDueToStateChangeL()
106 // Called from numerous places where content has
107 // changed, requiring a reformat of the current document.
110 iRichEd->NotifyNewFormatL();
111 UpdateToolbandButtonsL();
112 SetPaginationOutOfDate(ETrue);
116 void CWordAppUi::UpdateToolbarsL()
118 UpdateToolbandButtonsL();
119 UpdateFileNameLabelL();
123 void CWordAppUi::ResetEdwinL()
125 iRichEd->ScrollBarFrame()->SetScrollBarVisibilityL(CEikScrollBarFrame::EOff,CEikScrollBarFrame::EOff);
126 if (WysiwygModeIsSet())
127 iRichEd->SetWysiwygModeOn(PageLayoutWidth(),iModel->PrintSetup()->PrinterDevice());
129 iRichEd->SetWysiwygModeOff();
131 TInt adjacent=EGulAdjNone;
132 if (iEikonEnv->AppUiFactory()->ToolBar()->IsVisible())
133 adjacent |= EGulAdjRight;
134 if (iEikonEnv->AppUiFactory()->ToolBand()->IsVisible())
135 adjacent |= EGulAdjTop;
136 iRichEd->SetAdjacent(adjacent);
137 TViewYPosQualifier yPosQualifier;
138 yPosQualifier.SetMakeLineFullyVisible();
139 yPosQualifier.SetFillScreen();
140 yPosQualifier.SetHotSpot(TViewYPosQualifier::EFViewBottomOfLine);
141 TInt docPos=iRichEd->TextView()->Selection().iCursorPos;
142 TInt yPos=iRichEd->TextView()->ViewRect().iBr.iY;
143 iRichEd->TextView()->SetViewL(docPos,yPos,yPosQualifier,CTextView::EFViewDiscardAllNoRedraw); // !! casues format
144 iRichEd->SetRect(ClientRect()); // !! causes format but no draw
145 if (WysiwygModeIsSet())
146 iRichEd->ScrollBarFrame()->SetScrollBarVisibilityL(CEikScrollBarFrame::EAuto,CEikScrollBarFrame::EAuto);
148 iRichEd->ScrollBarFrame()->SetScrollBarVisibilityL(CEikScrollBarFrame::EOff,CEikScrollBarFrame::EAuto);
150 // for use when running as a main document.
151 // Read-only status is determined by looking at the AppFileMode.
153 SetReadOnly(iEmbeddedAndReadOnly);
155 SetReadOnly((TBool)!(iDocument->AppFileMode()&EFileWrite));
157 iRichEd->ForceScrollBarUpdateL();
158 iRichEd->NotifyNewFormatL(); // re-flow layout
159 iRichEd->DrawNow(); // !! causes draw
160 UpdateToolbandButtonsL(EVisibilityDependant);
161 UpdateFileNameLabelL();
162 iCoeEnv->WsSession().Flush();
165 void CWordAppUi::SetEdwinL()
167 iModel=Document()->Model();
168 iRichEd->SetDocumentContentL(*Text(),CEikEdwin::EUseText);
169 iRichEd->SetRect(ClientRect());
170 iRichEd->InitialiseUnifiedEditorL();
171 CFbsBitmap* lineCursor=iEikonEnv->CreateBitmapL(TPtrC(),EMbmEikonLncusr1);
172 iRichEd->SetLineCursorBitmapL(lineCursor);
175 void CWordAppUi::ResetPrint()
177 iPrintSetup=iModel->PrintSetup();
178 CTextPageRegionPrinter& printer=PageRegionPrinter();
179 printer.SetFirstPageOfDoc(KFirstPageNum);
180 printer.SetDocument(Text());
181 printer.SetPrinterDevice(iPrintSetup->PrinterDevice());
182 printer.SetPageList(iModel->PageTable());
183 printer.SetPageMarginsInTwips(iPrintSetup->iPageMarginsInTwips.iMargins);
184 printer.SetPageSpecInTwips(iPrintSetup->PrinterDevice()->CurrentPageSpecInTwips());
185 printer.SetParagraphFillTextOnly(ETrue);
188 void CWordAppUi::ResetFlags()
190 iAlignment = RTmParFormat::EAlignNormal;
191 iWordFlags &= EWysiwygModeOn;
194 void CWordAppUi::RunGoToDialogL()
196 TInt pageNo=1; // etext should provide a function that gives current page number.
197 TInt aMaxPages=iModel->PageTable()->Count();
198 CEikDialog* dialog=new(ELeave) CWordGoToDialog(aMaxPages,&pageNo);
199 if (!dialog->ExecuteLD(R_WORD_DIALOG_GOTO))
202 CArrayFix<TInt>* pageTable=iModel->PageTable();
203 for (TInt ii=0;ii<pageNo-1;ii++)
204 total+=(*pageTable)[ii];
205 iRichEd->SetCursorPosL(total,EFalse);
208 void CWordAppUi::SetBulletL()
210 TParaFormatMask mask;
211 CParaFormat* paraFormat = CParaFormat::NewLC();
212 const TCursorSelection cursorSelection = iRichEd->TextView()->Selection();
213 const TInt lower = cursorSelection.LowerPos();
214 const TInt selectionLength = cursorSelection.Length();
215 CRichText* text = Text();
216 text->GetParaFormatL(paraFormat, mask, lower, selectionLength);
217 delete paraFormat->iBullet;
219 mask.SetAttrib(EAttBullet);
220 mask.SetAttrib(EAttIndent);
221 if (((CEikButtonBase*)iEikonEnv->AppUiFactory()->ToolBand()->ControlById(EWordButtonBullets))->State() == CEikButtonBase::EClear)
223 paraFormat->iBullet = NULL;
224 paraFormat->iIndentInTwips = 0;
228 TBullet* bullet = new(ELeave) TBullet;
230 CreateDefaultBulletL();
232 paraFormat->iBullet = bullet;
233 if (iBullet->iHangingIndent)
234 paraFormat->iIndentInTwips = 283; // about 1/2cm - completely arbitrary value !!
236 paraFormat->iIndentInTwips = 0;
238 iRichEd->ApplyParaFormatL(paraFormat, mask);
239 CleanupStack::PopAndDestroy();
242 void CWordAppUi::RunSelectBulletDialogL()
245 CreateDefaultBulletL();
246 CParaFormat* paraFormat=CParaFormat::NewLC();
247 TParaFormatMask paraUndeterminedMask;
248 TCharFormat charFormat;
249 TCharFormatMask charFormatMask;
250 const TCursorSelection selection=iRichEd->TextView()->Selection();
251 Text()->GetParaFormatL(paraFormat,paraUndeterminedMask,selection.LowerPos(),selection.Length());
252 Text()->GetCharFormat(charFormat,charFormatMask,selection.LowerPos(),selection.Length());
253 TRgb backColor=paraFormat->iFillColor;
254 if (paraUndeterminedMask.AttribIsSet(EAttFillColor))
255 backColor=KRgbWhite; // what else could be done ???
256 if (paraFormat->iBullet)
257 *iBullet=*paraFormat->iBullet;
258 CEikDialog* dialog=new(ELeave) CWordBulletDialog(iBullet,backColor,NULL,charFormat.iFontSpec.iTypeface.iName);
259 if (dialog->ExecuteLD(R_WORD_DIALOG_BULLET))
261 CEikButtonBase* but = (CEikButtonBase*)iEikonEnv->AppUiFactory()->ToolBand()->ControlById(EWordButtonBullets);
262 but->SetState(CEikButtonBase::ESet);
266 CleanupStack::PopAndDestroy();
269 void CWordAppUi::CreateDefaultBulletL()
271 iBullet=new(ELeave) TBullet;
272 iBullet->iCharacterCode=0x2022;
273 iBullet->iHeightInTwips=iEikonEnv->NormalFont()->FontSpecInTwips().iHeight;
274 iBullet->iTypeface.iName=_L("Swiss");
277 void CWordAppUi::SetParaAlignmentL(TInt aIndex)
279 RTmParFormatLayer format;
280 format.iMask.iFlags = 0;
281 format.iMask.Set(TTmParFormatMask::EAlignment);
285 case EWordCmdAlignLeft:
286 format.iFormat.iAlignment = RTmParFormat::EAlignNormal;
289 case EWordCmdAlignCenter:
290 format.iFormat.iAlignment = RTmParFormat::EAlignCenter;
293 case EWordCmdAlignRight:
294 format.iFormat.iAlignment = RTmParFormat::EAlignReverse;
297 case EWordCmdAlignJustify:
298 format.iFormat.iAlignment = RTmParFormat::EAlignJustify;
301 format.iFormat.iAlignment = RTmParFormat::EAlignNormal;
303 TCursorSelection sel = iRichEd->Selection();
304 iRichEd->SetParFormatL(sel.LowerPos(),sel.Length(),format);
305 UpdateAlignButtonL(format.iFormat.iAlignment);
309 void CWordAppUi::CmdChangeAlignmentL()
312 TParaFormatMask undeterminedMask;
313 const TCursorSelection selection=iRichEd->Selection();
314 Text()->GetParaFormatL(&format,undeterminedMask,selection.LowerPos(),selection.Length());
316 TInt index=format.iHorizontalAlignment+1; // toggle the alignment
318 if (undeterminedMask.AttribIsSet(EAttAlignment))
319 index=4; // ...to force default case
322 index=0; // where alignment > justifed, make it left aligned.
323 SetParaAlignmentL(index);
327 void CWordAppUi::ZoomL(TInt aZoomCmd)
329 TInt zoomFactor=iAppZoom.ZoomFactor();
331 if (zoomFactor>KZoomStateFour)
332 zoomFactor=(aZoomCmd==EEikCmdZoomIn) ? KZoomStateOne : KZoomStateFour;
334 else if (zoomFactor==KZoomStateFour)
335 zoomFactor=(aZoomCmd==EEikCmdZoomIn) ? KZoomStateOne : KZoomStateThree;
337 else if (zoomFactor>KZoomStateThree)
338 zoomFactor=(aZoomCmd==EEikCmdZoomIn) ? KZoomStateFour : KZoomStateThree;
340 else if (zoomFactor==KZoomStateThree)
341 zoomFactor=(aZoomCmd==EEikCmdZoomIn) ? KZoomStateFour : KZoomStateTwo;
343 else if (zoomFactor>KZoomStateTwo)
344 zoomFactor=(aZoomCmd==EEikCmdZoomIn) ? KZoomStateThree : KZoomStateTwo;
346 else if (zoomFactor==KZoomStateTwo)
347 zoomFactor=(aZoomCmd==EEikCmdZoomIn) ? KZoomStateThree : KZoomStateOne;
349 else if (zoomFactor>KZoomStateOne)
350 zoomFactor=(aZoomCmd==EEikCmdZoomIn) ? KZoomStateTwo : KZoomStateOne;
352 else if (zoomFactor==KZoomStateOne)
353 zoomFactor=(aZoomCmd==EEikCmdZoomIn) ? KZoomStateTwo : KZoomStateFour;
356 zoomFactor=(aZoomCmd==EEikCmdZoomIn) ? KZoomStateOne : KZoomStateFour;
358 iAppZoom.SetZoomFactor(zoomFactor);
359 TInt bitmapId=EMbmEikonLncusr1;
365 case KZoomStateThree:
366 bitmapId=EMbmEikonLncusr3;
369 bitmapId=EMbmEikonLncusr4;
374 CFbsBitmap* lineCursor=iEikonEnv->CreateBitmapL(TPtrC(),bitmapId);
375 iRichEd->SetLineCursorBitmapL(lineCursor);
376 iRichEd->NotifyNewFormatL();
379 void CWordAppUi::InsertCharacterL(TChar aCharacter)
381 iRichEd->InsertCharacterL(aCharacter);
382 UpdateToolbandButtonsL();
383 SetPaginationOutOfDate(ETrue);
385 if (aCharacter==CEditableText::EPageBreak)
386 RunPaginationDialogL();
389 void CWordAppUi::CmdWrapToScreenL()
390 // Toggle the state of the screen mapping.
391 // Swaps between wrap to screen and wrap to page width
394 TBool wysiwygModeNowOn=ToggleWysiwygMode();
395 CEikScrollBarFrame::TScrollBarVisibility horizVisibility=(wysiwygModeNowOn)
396 ? CEikScrollBarFrame::EAuto
397 : CEikScrollBarFrame::EOff;
398 iRichEd->ScrollBarFrame()->SetScrollBarVisibilityL(horizVisibility,CEikScrollBarFrame::EAuto);
400 if (wysiwygModeNowOn)
401 UpdatePageLayoutL(); // wrap to the page width
403 {// wrap to screen width
404 iRichEd->SetWysiwygModeOff();
405 iRichEd->NotifyNewFormatL();
410 void CWordAppUi::UpdatePageLayoutL()
412 if (WysiwygModeIsSet())
414 iRichEd->SetWysiwygModeOn(PageLayoutWidth(),iModel->PrintSetup()->PrinterDevice());
415 iRichEd->NotifyNewFormatL();
419 TInt CWordAppUi::PageLayoutWidth() const
421 const CPrintSetup* print=Document()->Model()->PrintSetup();
422 const TPageSpec pageSpec=print->PrinterDevice()->CurrentPageSpecInTwips();
423 TInt width=(pageSpec.iOrientation? pageSpec.iPortraitPageSize.iHeight : pageSpec.iPortraitPageSize.iWidth);
424 const TMargins margins=print->iPageMarginsInTwips.iMargins;
425 width-=(margins.iLeft+margins.iRight);
429 void CWordAppUi::RunViewPreferencesDialogL()
431 TNonPrintingCharVisibility visibility=iRichEd->TextLayout()->NonPrintingCharsVisibility();
432 CWordViewPreferencesDialog* dialog=new(ELeave) CWordViewPreferencesDialog(visibility);
433 if (dialog->ExecuteLD(R_WORD_DIALOG_VIEW_PREFERENCES))
435 visibility.SetPageBreaksVisible(ETrue); // for now this is the default
436 iRichEd->TextLayout()->SetNonPrintingCharsVisibility(visibility);
437 iRichEd->NotifyNewFormatL();
442 void CWordAppUi::RunObjectPreferencesDialogL()
444 TBool sketchAsGlass=SketchAsGlass();
445 TBool graphAsGlass=GraphAsGlass();
446 CWordObjectPreferencesDialog* dialog=new(ELeave) CWordObjectPreferencesDialog(sketchAsGlass,graphAsGlass);
447 if (dialog->ExecuteLD(R_WORD_DIALOG_OBJECT_PREFERENCES))
449 SetSketchAsGlass(sketchAsGlass);
450 SetGraphAsGlass(graphAsGlass);
454 void CWordAppUi::RunOutlineDialogL()
456 TInt newCursorPosition = 0;
458 CEikDialog* dialog = new(ELeave) CWordOutlineDialog(Document()->Model()->Text(), iRichEd, newCursorPosition);
460 if (dialog->ExecuteLD(R_WORD_DIALOG_OUTLINE))
462 iRichEd->SetCursorPosL(newCursorPosition,EFalse);
463 if (iEikonEnv->AppUiFactory()->ToolBar()->IsVisible() || iEikonEnv->AppUiFactory()->ToolBand()->IsVisible())
464 iToolBarUpdate->Start(CWordToolBarUpdate::EFullUpdate);
469 TFileName CWordAppUi::BitmapStore() const
475 TBool CWordAppUi::RunPaginationDialogL()
477 TPageTable* pageTable=iModel->PageTable();
478 const TBool paginationCancelled=iRichEd->RunPaginateDialogL(iPrintSetup,pageTable);
479 if (!paginationCancelled)
481 iPrintParameters.iFirstPage=0;
482 iPrintParameters.iLastPage=pageTable->Count()-1;
483 SetPaginationOutOfDate(EFalse);
484 Text()->SetPageTable(pageTable);
485 iRichEd->DrawNow(); // need to display any page breaks immediatley.
487 return paginationCancelled;
491 void CWordAppUi::RunPreviewDialogL()
495 TBool paginationCancelled=EFalse;
496 if (PaginationOutOfDate())
497 paginationCancelled=RunPaginationDialogL();
498 if (paginationCancelled)
501 TInt totalNumPages=iModel->PageTable()->Count();
502 CTextPageRegionPrinter& printer=PageRegionPrinter();
503 printer.SetPrintPreview(ETrue);
504 if (CEikPrintPreviewDialog::RunDlgLD(*iPrintSetup, printer, totalNumPages, this, KPrintPreviewBandsPerPage))
509 TBool CWordAppUi::PageSetupChangedL(CPrintSetup* aPrintSetup,TInt& aNumPagesInDoc)
510 // Return ETrue if pagination is cancelled, otherwise return EFalse.
513 CTextPageRegionPrinter& printer=PageRegionPrinter();
514 printer.SetPageMarginsInTwips(aPrintSetup->iPageMarginsInTwips.iMargins);
515 printer.SetPageSpecInTwips(aPrintSetup->PrinterDevice()->CurrentPageSpecInTwips());
516 SetPaginationOutOfDate(ETrue);
518 if (RunPaginationDialogL())
520 aNumPagesInDoc=iModel->PageTable()->Count();
525 TBool CWordAppUi::RunPrintRangeDialogL(CPrintSetup* aPrintSetup,TInt& aNumPagesInDoc)
526 // Return ETrue if pagination is cancelled, otherwise return EFalse.
529 TUid oldUid = aPrintSetup->PrinterDevice()->Model().iUid;
531 CEikPrintRangeDialog* dialog = new(ELeave) CEikPrintRangeDialog(iPrintParameters, aPrintSetup, uid);
534 // an Eikon defect that cannot be fixed without breaking binary compatibility
536 dialog->iPageRange.iLowerLimit = 1; //
537 dialog->iPageRange.iUpperLimit = iModel->PageTable()->Count();
538 dialog->ExecuteLD(R_EIK_DIALOG_PRINT_RANGE_SETUP);
541 aPrintSetup->CreatePrinterDeviceL(uid, iEikonEnv->FsSession());
542 CTextPageRegionPrinter& printer = PageRegionPrinter();
543 printer.SetPrinterDevice(aPrintSetup->PrinterDevice());
546 SetPaginationOutOfDate(ETrue);
547 if (RunPaginationDialogL())
550 aNumPagesInDoc = iModel->PageTable()->Count();
551 return EFalse; // no cancellation during pagination
554 void CWordAppUi::RunPrintDialogL()
556 TUid oldUid = iPrintSetup->PrinterDevice()->Model().iUid;
558 CEikPrintRangeDialog* dialog = new(ELeave) CEikPrintRangeDialog(iPrintParameters, iPrintSetup, uid, ETrue);
561 // an Eikon defect that cannot be fixed without breaking binary compatibility
563 dialog->iPageRange.iLowerLimit = 1; //
564 dialog->iPageRange.iUpperLimit = iModel->PageTable()->Count();;
565 if (dialog->ExecuteLD(R_EIK_DIALOG_PRINT_RANGE_SETUP))
569 iPrintSetup->CreatePrinterDeviceL(uid, iEikonEnv->FsSession());
570 CTextPageRegionPrinter& printer = PageRegionPrinter();
571 printer.SetPrinterDevice(iPrintSetup->PrinterDevice());
574 SetPaginationOutOfDate(ETrue);
579 TBool cancel = EFalse;
580 if (PaginationOutOfDate())
581 cancel = RunPaginationDialogL();
588 void CWordAppUi::DoPrintL()
589 // Run the print progress dialog
592 CTextPageRegionPrinter& printer=PageRegionPrinter();
593 printer.SetPrintPreview(EFalse);
594 CEikPrintProgressDialog::RunDlgLD(iPrintSetup, &printer, iPrintParameters);
595 iPrintSetup->FreeModelList();
599 TBool CWordAppUi::ConfirmationDialogL(TConfirmationText aTitle,TConfirmationText aText)const
600 // Generate a query window with the specified text.
603 TResourceReader reader;
604 return iEikonEnv->QueryWinL(reader.ReadTPtrC(aTitle,MUTABLE_CAST(HBufC8*,iConfirmationText)),
605 reader.ReadTPtrC(aText,MUTABLE_CAST(HBufC8*,iConfirmationText)) );
609 void CWordAppUi::GetUiData(TWordUiData& aData)const
612 aData.iNpcVisibility=0;
613 if (!(iRichEd && iRichEd->TextLayout()))
615 TNonPrintingCharVisibility visibility=iRichEd->TextLayout()->NonPrintingCharsVisibility();
616 if (visibility.TabsVisible())
617 aData.iNpcVisibility|=ENpcTabsVisible;
618 if (visibility.SpacesVisible())
619 aData.iNpcVisibility|=ENpcSpacesVisible;
620 if (visibility.ParagraphDelimitersVisible())
621 aData.iNpcVisibility|=NpcParagraphsVisible;
622 if (visibility.LineBreaksVisible())
623 aData.iNpcVisibility|=NpcForcedLineBreaksVisible;
624 if (visibility.PotentialHyphensVisible())
625 aData.iNpcVisibility|=NpcSoftHyphensVisible;
626 if (visibility.NonBreakingHyphensVisible())
627 aData.iNpcVisibility|=NpcHardHyphensVisible;
628 if (visibility.NonBreakingSpacesVisible())
629 aData.iNpcVisibility|=NpcHardSpacesVisible;
631 // sketch/graph default appearance
632 aData.iPicturePrefs=0;
633 aData.iPicturePrefs=iPicturePrefs;
636 aData.iCursorPos=iRichEd->CursorPos();
638 // toolbar visibilities
639 aData.iToolbandVisibility = iEikonEnv->AppUiFactory()->ToolBand()->IsVisible();
640 aData.iToolbarVisibility = iEikonEnv->AppUiFactory()->ToolBar()->IsVisible();
643 aData.iZoomFactor=iAppZoom.ZoomFactor();
646 aData.iWysiwygOn=WysiwygModeIsSet();
650 void CWordAppUi::SetUiData()
652 const TWordUiData& data=Document()->UiData();
654 // Non-printing-char prefs
655 TNonPrintingCharVisibility visibility;
656 visibility.SetPageBreaksVisible(ETrue);
657 visibility.SetTabsVisible(data.iNpcVisibility&ENpcTabsVisible);
658 visibility.SetSpacesVisible(data.iNpcVisibility&ENpcSpacesVisible);
659 visibility.SetParagraphDelimitersVisible(data.iNpcVisibility&NpcParagraphsVisible);
660 visibility.SetLineBreaksVisible(data.iNpcVisibility&NpcForcedLineBreaksVisible);
661 visibility.SetPotentialHyphensVisible(data.iNpcVisibility&NpcSoftHyphensVisible);
662 visibility.SetNonBreakingHyphensVisible(data.iNpcVisibility&NpcHardHyphensVisible);
663 visibility.SetNonBreakingSpacesVisible(data.iNpcVisibility&NpcHardSpacesVisible);
664 iRichEd->TextLayout()->SetNonPrintingCharsVisibility(visibility);
666 // sketch/graph default appearance
667 iPicturePrefs=data.iPicturePrefs;
670 iRichEd->TextView()->SetPendingSelection(TCursorSelection(data.iCursorPos,data.iCursorPos));
672 // toolbar visibilites
673 iEikonEnv->AppUiFactory()->ToolBand()->MakeVisible(data.iToolbandVisibility);
674 iEikonEnv->AppUiFactory()->ToolBar()->MakeVisible(data.iToolbarVisibility);
677 iAppZoom.SetZoomFactor(data.iZoomFactor);
681 iWordFlags|=EWysiwygModeOn;
683 iWordFlags&=~EWysiwygModeOn;
687 TWordUiData::TWordUiData()
690 iToolbandVisibility(ETrue),
691 iToolbarVisibility(ETrue),
693 iZoomFactor(KDefaultZoomState),
698 void TWordUiData::Reset()
702 iToolbandVisibility=ETrue;
703 iToolbarVisibility=ETrue;
705 iZoomFactor=KDefaultZoomState;
710 void TWordUiData::InternalizeL(RReadStream& aStream)
712 TCardinality version;
713 version.InternalizeL(aStream);
714 if (version!=KVersionAppConfigurationData)
715 User::Leave(KErrCorrupt); // !! need better error
718 iNpcVisibility=aStream.ReadUint8L();
720 iPicturePrefs=aStream.ReadUint8L();
721 iToolbandVisibility=(TBool)aStream.ReadInt8L();
722 iToolbarVisibility=(TBool)aStream.ReadInt8L();
723 iWysiwygOn=(TBool)aStream.ReadInt8L();
725 iCursorPos=aStream.ReadInt32L();
726 iZoomFactor=aStream.ReadInt32L();
730 void TWordUiData::ExternalizeL(RWriteStream& aStream) const
732 const TCardinality version=KVersionAppConfigurationData;
733 version.ExternalizeL(aStream);
735 aStream.WriteUint8L((TUint8)iNpcVisibility);
736 aStream.WriteUint8L((TUint8)iPicturePrefs);
737 aStream.WriteInt8L(iToolbandVisibility);
738 aStream.WriteInt8L(iToolbarVisibility);
739 aStream.WriteInt8L(iWysiwygOn);
741 aStream.WriteInt32L(iCursorPos);
742 aStream.WriteInt32L(iZoomFactor);