Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 :
20 : #include <hintids.hxx>
21 : #include <svx/svditer.hxx>
22 : #include <svx/svdotext.hxx>
23 : #include <editeng/editdata.hxx>
24 : #include <svx/svdpagv.hxx>
25 : #include <svx/svdogrp.hxx>
26 : #include <sfx2/printer.hxx>
27 : #include <svx/svdmodel.hxx>
28 : #include <editeng/langitem.hxx>
29 : #include <com/sun/star/beans/XPropertySet.hpp>
30 : #include <linguistic/lngprops.hxx>
31 : #include <sfx2/sfxuno.hxx>
32 : #include <svx/svdview.hxx>
33 : #include <editeng/unolingu.hxx>
34 : #include <unotools/localedatawrapper.hxx>
35 : #include <sdrhhcwrap.hxx>
36 : #include <frmfmt.hxx>
37 : #include <docsh.hxx> // " " "
38 : #include <wrtsh.hxx> // MakeVisible
39 : #include <view.hxx>
40 : #include <dcontact.hxx> // Spelling von DrawObj
41 : #include <doc.hxx> // " " "
42 : #include <docary.hxx>
43 : #include <edtwin.hxx>
44 :
45 : using namespace ::com::sun::star;
46 :
47 : //////////////////////////////////////////////////////////////////////
48 :
49 0 : SdrHHCWrapper::SdrHHCWrapper( SwView* pVw,
50 : LanguageType nSourceLanguage, LanguageType nTargetLanguage,
51 : const Font* pTargetFnt,
52 : sal_Int32 nConvOptions,
53 : bool bInteractive ) :
54 0 : SdrOutliner(pVw->GetDocShell()->GetDoc()->GetDrawModel()->
55 0 : GetDrawOutliner().GetEmptyItemSet().GetPool(),
56 : OUTLINERMODE_TEXTOBJECT ),
57 : pView( pVw ),
58 : pTextObj( NULL ),
59 : pOutlView( NULL ),
60 : nOptions( nConvOptions ),
61 : nDocIndex( 0 ),
62 : nSourceLang( nSourceLanguage ),
63 : nTargetLang( nTargetLanguage ),
64 : pTargetFont( pTargetFnt ),
65 0 : bIsInteractive( bInteractive )
66 : {
67 0 : SetRefDevice( pView->GetDocShell()->GetDoc()->getPrinter( false ) );
68 :
69 0 : MapMode aMapMode (MAP_TWIP);
70 0 : SetRefMapMode(aMapMode);
71 :
72 0 : Size aSize( 1, 1 );
73 0 : SetPaperSize( aSize );
74 :
75 0 : pOutlView = new OutlinerView( this, &(pView->GetEditWin()) );
76 0 : pOutlView->GetOutliner()->SetRefDevice(pView->GetWrtShell().getIDocumentDeviceAccess()->getPrinter( false ));
77 :
78 : // Hack: all SdrTextObj attributes should be transferred to EditEngine
79 0 : pOutlView->SetBackgroundColor( Color( COL_WHITE ) );
80 :
81 :
82 0 : InsertView( pOutlView );
83 0 : Point aPoint( 0, 0 );
84 0 : Rectangle aRect( aPoint, aSize );
85 0 : pOutlView->SetOutputArea( aRect );
86 : // SetText( NULL );
87 0 : ClearModifyFlag();
88 0 : }
89 :
90 0 : SdrHHCWrapper::~SdrHHCWrapper()
91 : {
92 0 : if (pTextObj)
93 : {
94 0 : SdrView *pSdrView = pView->GetWrtShell().GetDrawView();
95 : OSL_ENSURE( pSdrView, "SdrHHCWrapper without DrawView?" );
96 0 : pSdrView->SdrEndTextEdit( sal_True );
97 0 : SetUpdateMode(sal_False);
98 0 : pOutlView->SetOutputArea( Rectangle( Point(), Size(1, 1) ) );
99 : }
100 0 : RemoveView( pOutlView );
101 0 : delete pOutlView;
102 0 : }
103 :
104 :
105 0 : void SdrHHCWrapper::StartTextConversion()
106 : {
107 0 : pOutlView->StartTextConversion( nSourceLang, nTargetLang, pTargetFont, nOptions, static_cast<sal_Bool>(bIsInteractive), sal_True );
108 0 : }
109 :
110 :
111 0 : sal_Bool SdrHHCWrapper::ConvertNextDocument()
112 : {
113 0 : sal_Bool bNextDoc = sal_False;
114 :
115 0 : if ( pTextObj )
116 : {
117 0 : SdrView *pSdrView = pView->GetWrtShell().GetDrawView();
118 : OSL_ENSURE( pSdrView, "SdrHHCWrapper without DrawView?" );
119 0 : pSdrView->SdrEndTextEdit( sal_True );
120 0 : SetUpdateMode(sal_False);
121 0 : pOutlView->SetOutputArea( Rectangle( Point(), Size(1, 1) ) );
122 0 : SetPaperSize( Size(1, 1) );
123 0 : Clear();
124 0 : pTextObj = NULL;
125 : }
126 :
127 0 : sal_uInt16 n = nDocIndex;
128 :
129 0 : std::list<SdrTextObj*> aTextObjs;
130 0 : SwDrawContact::GetTextObjectsFromFmt( aTextObjs, pView->GetDocShell()->GetDoc() );
131 0 : for ( std::list<SdrTextObj*>::iterator aIt = aTextObjs.begin(); aIt != aTextObjs.end(); ++aIt )
132 : {
133 0 : pTextObj = (*aIt);
134 0 : if ( pTextObj )
135 : {
136 0 : OutlinerParaObject* pParaObj = pTextObj->GetOutlinerParaObject();
137 0 : if ( pParaObj )
138 : {
139 0 : SetPaperSize( pTextObj->GetLogicRect().GetSize() );
140 0 : SetText( *pParaObj );
141 :
142 0 : ClearModifyFlag();
143 :
144 : //!! update mode needs to be set to true otherwise
145 : //!! the call to 'HasConvertibleTextPortion' will not always
146 : //!! work correctly because the document may not be properly
147 : //!! formatted when some information is accessed, and thus
148 : //!! incorrect results get returned.
149 0 : SetUpdateMode(sal_True);
150 0 : if (HasConvertibleTextPortion( nSourceLang ))
151 : {
152 0 : SdrView *pSdrView = pView->GetWrtShell().GetDrawView();
153 : OSL_ENSURE( pSdrView, "SdrHHCWrapper without DrawView?" );
154 0 : SdrPageView* pPV = pSdrView->GetSdrPageView();
155 0 : nDocIndex = n;
156 0 : bNextDoc = sal_True;
157 0 : pOutlView->SetOutputArea( Rectangle( Point(), Size(1,1)));
158 0 : SetPaperSize( pTextObj->GetLogicRect().GetSize() );
159 0 : SetUpdateMode(sal_True);
160 0 : pView->GetWrtShell().MakeVisible(pTextObj->GetLogicRect());
161 :
162 0 : pSdrView->SdrBeginTextEdit(pTextObj, pPV, &pView->GetEditWin(), sal_False, this, pOutlView, sal_True, sal_True);
163 : }
164 : else
165 0 : SetUpdateMode(sal_False);
166 : }
167 :
168 0 : if ( !bNextDoc )
169 0 : pTextObj = NULL;
170 : else
171 0 : break;
172 : }
173 : }
174 :
175 0 : ClearModifyFlag();
176 :
177 0 : return bNextDoc;
178 99 : }
179 :
180 : //////////////////////////////////////////////////////////////////////
181 :
182 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|