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 <drawdoc.hxx>
36 : #include <sdrhhcwrap.hxx>
37 : #include <frmfmt.hxx>
38 : #include <docsh.hxx>
39 : #include <wrtsh.hxx>
40 : #include <view.hxx>
41 : #include <dcontact.hxx>
42 : #include <doc.hxx>
43 : #include <IDocumentDeviceAccess.hxx>
44 : #include <IDocumentDrawModelAccess.hxx>
45 : #include <docary.hxx>
46 : #include <edtwin.hxx>
47 :
48 : using namespace ::com::sun::star;
49 :
50 0 : SdrHHCWrapper::SdrHHCWrapper( SwView* pVw,
51 : LanguageType nSourceLanguage, LanguageType nTargetLanguage,
52 : const vcl::Font* pTargetFnt,
53 : sal_Int32 nConvOptions,
54 : bool bInteractive ) :
55 0 : SdrOutliner(pVw->GetDocShell()->GetDoc()->getIDocumentDrawModelAccess().GetDrawModel()->
56 0 : GetDrawOutliner().GetEmptyItemSet().GetPool(),
57 : OUTLINERMODE_TEXTOBJECT ),
58 : pView( pVw ),
59 : pTextObj( NULL ),
60 : pOutlView( NULL ),
61 : nOptions( nConvOptions ),
62 : nDocIndex( 0 ),
63 : nSourceLang( nSourceLanguage ),
64 : nTargetLang( nTargetLanguage ),
65 : pTargetFont( pTargetFnt ),
66 0 : bIsInteractive( bInteractive )
67 : {
68 0 : SetRefDevice( pView->GetDocShell()->GetDoc()->getIDocumentDeviceAccess().getPrinter( false ) );
69 :
70 0 : MapMode aMapMode (MAP_TWIP);
71 0 : SetRefMapMode(aMapMode);
72 :
73 0 : Size aSize( 1, 1 );
74 0 : SetPaperSize( aSize );
75 :
76 0 : pOutlView = new OutlinerView( this, &(pView->GetEditWin()) );
77 0 : pOutlView->GetOutliner()->SetRefDevice(pView->GetWrtShell().getIDocumentDeviceAccess()->getPrinter( false ));
78 :
79 : // Hack: all SdrTextObj attributes should be transferred to EditEngine
80 0 : pOutlView->SetBackgroundColor( Color( COL_WHITE ) );
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( true );
97 0 : SetUpdateMode(false);
98 0 : pOutlView->SetOutputArea( Rectangle( Point(), Size(1, 1) ) );
99 : }
100 0 : RemoveView( pOutlView );
101 0 : delete pOutlView;
102 0 : }
103 :
104 0 : void SdrHHCWrapper::StartTextConversion()
105 : {
106 0 : pOutlView->StartTextConversion( nSourceLang, nTargetLang, pTargetFont, nOptions, bIsInteractive, true );
107 0 : }
108 :
109 0 : bool SdrHHCWrapper::ConvertNextDocument()
110 : {
111 0 : bool bNextDoc = false;
112 :
113 0 : if ( pTextObj )
114 : {
115 0 : SdrView *pSdrView = pView->GetWrtShell().GetDrawView();
116 : OSL_ENSURE( pSdrView, "SdrHHCWrapper without DrawView?" );
117 0 : pSdrView->SdrEndTextEdit( true );
118 0 : SetUpdateMode(false);
119 0 : pOutlView->SetOutputArea( Rectangle( Point(), Size(1, 1) ) );
120 0 : SetPaperSize( Size(1, 1) );
121 0 : Clear();
122 0 : pTextObj = NULL;
123 : }
124 :
125 0 : sal_uInt16 n = nDocIndex;
126 :
127 0 : std::list<SdrTextObj*> aTextObjs;
128 0 : SwDrawContact::GetTextObjectsFromFmt( aTextObjs, pView->GetDocShell()->GetDoc() );
129 0 : for ( std::list<SdrTextObj*>::iterator aIt = aTextObjs.begin(); aIt != aTextObjs.end(); ++aIt )
130 : {
131 0 : pTextObj = (*aIt);
132 0 : if ( pTextObj )
133 : {
134 0 : OutlinerParaObject* pParaObj = pTextObj->GetOutlinerParaObject();
135 0 : if ( pParaObj )
136 : {
137 0 : SetPaperSize( pTextObj->GetLogicRect().GetSize() );
138 0 : SetText( *pParaObj );
139 :
140 0 : ClearModifyFlag();
141 :
142 : //!! update mode needs to be set to true otherwise
143 : //!! the call to 'HasConvertibleTextPortion' will not always
144 : //!! work correctly because the document may not be properly
145 : //!! formatted when some information is accessed, and thus
146 : //!! incorrect results get returned.
147 0 : SetUpdateMode(true);
148 0 : if (HasConvertibleTextPortion( nSourceLang ))
149 : {
150 0 : SdrView *pSdrView = pView->GetWrtShell().GetDrawView();
151 : OSL_ENSURE( pSdrView, "SdrHHCWrapper without DrawView?" );
152 0 : SdrPageView* pPV = pSdrView->GetSdrPageView();
153 0 : nDocIndex = n;
154 0 : bNextDoc = true;
155 0 : pOutlView->SetOutputArea( Rectangle( Point(), Size(1,1)));
156 0 : SetPaperSize( pTextObj->GetLogicRect().GetSize() );
157 0 : SetUpdateMode(true);
158 0 : pView->GetWrtShell().MakeVisible(pTextObj->GetLogicRect());
159 :
160 0 : pSdrView->SdrBeginTextEdit(pTextObj, pPV, &pView->GetEditWin(), false, this, pOutlView, true, true);
161 : }
162 : else
163 0 : SetUpdateMode(false);
164 : }
165 :
166 0 : if ( !bNextDoc )
167 0 : pTextObj = NULL;
168 : else
169 0 : break;
170 : }
171 : }
172 :
173 0 : ClearModifyFlag();
174 :
175 0 : return bNextDoc;
176 270 : }
177 :
178 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|